//
//  DiaryCell.m
//  Lovely Food
//
//  Created by 李经纬 on 15/12/8.
//  Copyright © 2015年 李经纬. All rights reserved.
//

#import "DiaryCell.h"
#define KscreenHeight [[UIScreen mainScreen] bounds].size.height
#define KscreenWidth [[UIScreen mainScreen] bounds].size.width
@implementation DiaryCell
-(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
        
        [self setupViews];
        
    }
    return self;
}


-(void)setupViews
{
    self.userPhotoImage = [[UIImageView alloc]init];
    self.userPhotoImage.backgroundColor = [UIColor redColor];
    [self.contentView addSubview:self.userPhotoImage];
    
    
    self.titleNameLabel = [[UILabel alloc]init];
    self.titleNameLabel.backgroundColor = [UIColor orangeColor];
    [self.contentView addSubview:self.titleNameLabel];
    
    self.cityIconLabel = [[UILabel alloc]init];
    self.cityIconLabel.backgroundColor = [UIColor yellowColor];
    [self.contentView addSubview:self.cityIconLabel];
    
    self.cityLabel = [[UILabel alloc]init];
    self.cityLabel.backgroundColor = [UIColor greenColor];
    [self.contentView addSubview:self.cityLabel];
    
    self.userNameIconLabel = [[UILabel alloc]init];
    self.userNameIconLabel.backgroundColor = [UIColor cyanColor];
    [self.contentView addSubview:self.userNameIconLabel];
    
    self.userNameLabel = [[UILabel alloc]init];
    self.userNameLabel.backgroundColor = [UIColor blueColor];
    [self.contentView addSubview:self.userNameLabel];
    
    self.dataIconLabel = [[UILabel alloc]init];
    self.dataIconLabel.backgroundColor = [UIColor purpleColor];
    [self.contentView addSubview:self.dataIconLabel];
    
    self.dataLabel = [[UILabel alloc]init];
    self.dataLabel.backgroundColor = [UIColor grayColor];
    [self.contentView addSubview:self.dataLabel];
    
    self.likeIconLabel = [[UILabel alloc]init];
    self.likeIconLabel.backgroundColor = [UIColor brownColor];
    [self.contentView addSubview:self.likeIconLabel];
    
    self.likeLabel = [[UILabel alloc]init];
    self.likeLabel.backgroundColor = [UIColor cyanColor];
    [self.contentView addSubview:self.likeLabel];
    
    self.troveIconLabel = [[UILabel alloc]init];
    self.troveIconLabel.backgroundColor = [UIColor redColor];
    [self.contentView addSubview:self.troveIconLabel];
    
    self.troveLabel = [[UILabel alloc]init];
    self.troveLabel.backgroundColor = [UIColor yellowColor];
    [self.contentView addSubview:self.troveLabel];
    
    self.foodImage = [[UIImageView alloc]init];
    self.foodImage.backgroundColor = [UIColor greenColor];
    [self.contentView addSubview:self.foodImage];
    
}

-(void)layoutSubviews
{
    [super layoutSubviews];
    self.foodImage.frame = CGRectMake(10, 10, KscreenWidth-20, KscreenWidth/2+10);
    
    self.titleNameLabel.frame = CGRectMake(CGRectGetMinX(self.foodImage.frame), CGRectGetMaxY(self.foodImage.frame)+5, CGRectGetWidth(self.foodImage.frame)*0.8, CGRectGetHeight(self.foodImage.frame)/7);
    
    self.cityIconLabel.frame = CGRectMake(CGRectGetMinX(self.foodImage.frame), CGRectGetMaxY(self.titleNameLabel.frame)+5, CGRectGetWidth(self.titleNameLabel.frame)*0.1, CGRectGetHeight(self.titleNameLabel.frame));
    
    self.cityLabel.frame = CGRectMake(CGRectGetMaxX(self.cityIconLabel.frame) + 5, CGRectGetMinY(self.cityIconLabel.frame), CGRectGetWidth(self.cityIconLabel.frame)*7, CGRectGetHeight(self.cityIconLabel.frame));
    
    self.userNameIconLabel.frame = CGRectMake(CGRectGetMinX(self.cityIconLabel.frame), CGRectGetMaxY(self.cityIconLabel.frame)+5, CGRectGetWidth(self.cityIconLabel.frame), CGRectGetHeight(self.cityIconLabel.frame));
    
    self.userNameLabel.frame = CGRectMake(CGRectGetMinX(self.cityLabel.frame), CGRectGetMaxY(self.cityLabel.frame)+5, CGRectGetWidth(self.cityLabel.frame), CGRectGetHeight(self.cityLabel.frame));
    
    self.userPhotoImage.frame = CGRectMake(CGRectGetMaxX(self.bounds)-80, CGRectGetMaxY(self.foodImage.frame)+5, 50, 50);
    
    self.likeIconLabel.frame = CGRectMake(CGRectGetMaxX(self.userNameLabel.frame)+5, CGRectGetMinY(self.userNameLabel.frame), CGRectGetWidth(self.userNameIconLabel.frame), CGRectGetHeight(self.userNameIconLabel.frame));
    
    self.likeLabel.frame = CGRectMake(CGRectGetMaxX(self.likeIconLabel.frame), CGRectGetMinY(self.likeIconLabel.frame), CGRectGetWidth(self.likeIconLabel.frame), CGRectGetHeight(self.likeIconLabel.frame));
    
    self.troveIconLabel.frame = CGRectMake(CGRectGetMaxX(self.likeLabel.frame), CGRectGetMinY(self.likeLabel.frame), CGRectGetWidth(self.likeLabel.frame), CGRectGetHeight(self.likeLabel.frame));
    
    self.troveLabel.frame = CGRectMake(CGRectGetMaxX(self.troveIconLabel.frame), CGRectGetMinY(self.troveIconLabel.frame), CGRectGetWidth(self.troveIconLabel.frame), CGRectGetHeight(self.troveIconLabel.frame));
    
}





- (void)awakeFromNib {
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];
    
    // Configure the view for the selected state
}

@end
